package com.zmn.oms.admin.controller.conf.reply.content;

import com.zmn.common.constant.GlobalConsts;
import com.zmn.common.dictionary.GlobalDict;
import com.zmn.oms.model.entity.conf.reply.ReplyContent;
import com.zmn.oms.model.entity.conf.reply.ReplyContentQuery;
import com.zmn.oms.model.vo.conf.reply.ReplyContentVO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * 类描述:回访内容列表控制器
 *
 * @author linfeng
 * @since 2019/10/21/14:46
 */
@Controller
@RequestMapping(value = "/conf/reply/content/")
public class ReplyContentListController extends ReplyContentBaseController {
    private Logger logger = LoggerFactory.getLogger(ReplyContentListController.class);

    @RequestMapping(value = "list")
    //@RequiresPermissions("/orderconfig/returnvisitcontent/list.action")
    public ModelAndView list(@ModelAttribute ReplyContentQuery query) {
        List<ReplyContentVO> items = replyContentBService.listPageByQuery(query);

        ModelAndView mav = new ModelAndView("conf/reply/content/list");
        mav.addObject("vo", query);
        mav.addObject("platTypeList", GlobalConsts.getPlatList());
        mav.addObject("items", items);

        return mav;
    }

    @RequestMapping(value = "detail")
    //@RequiresPermissions("/orderconfig/returnvisitcontent/detail.action")
    public ModelAndView detail(@RequestParam(value = "id", defaultValue = "0") Integer id) {
        ReplyContent replyContent;
        if (id > 0) {
            replyContent = replyContentService.findByKey(id);
        } else {
            replyContent = new ReplyContent();
        }

        ModelAndView mav = new ModelAndView("conf/reply/content/detail");

        mav.addObject("statuses", GlobalDict.getStatusList(false));
        mav.addObject("vo", id);
        mav.addObject("returnVisitContent", replyContent);
        return mav;
    }
}
